package org.ucas.kgraph.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.ucas.kgraph.entity.Schem;
import org.ucas.kgraph.entity.Term;

import java.util.List;

@Repository
public interface SchemDao extends JpaRepository<Schem,Long>{

  @Query("FROM Schem t WHERE t.account_id = ?1 AND t.type = ?2 AND t.state=?3 AND t.file_id=?4")
  public List<Schem> findByAccountId(Long account_id,String type,String state,Long file_id);
 
  @Query("FROM Schem t WHERE t.type = ?1 AND t.state = ?2 AND t.file_id=?3")
  public List<Schem> findByAll(String type, String state, Long file_id);

  @Query("FROM Schem t WHERE t.root like %?1% AND t.type = ?2 AND t.state = ?3")
  public List<Schem> searchByRoot(String root,String type, String state);
  
  @Query("FROM Schem t WHERE t.file_id=?1")
  public List<Schem> findByAllByFile(Long id);
 
  @Query("FROM Schem t WHERE t.type = ?1 AND t.state = ?2 AND t.file_id=?3 AND t.root like %?4%")
  public List findByAll(String type, String state, Long file_id, String searchString);
}
